package yinwei.bo.common.entry;

import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Data;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

@Data
public class Comment {

    private static final long serialVersionUID = 1L;

    /*@JsonSerialize(using = ToStringSerializer.class) //系统序列化时，保留相关精度
    @ApiModelProperty(value = "评论id")*/
    private Long id;

    /*@ApiModelProperty(value = "是否为管理员评论")*/
    private Boolean adminComment;

    /*@ApiModelProperty(value = "头像")*/
    private String avatar;

    /*@ApiModelProperty(value = "评论内容")*/
    private String content;

    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", timezone = "Asia/ShangHai")
    /*@ApiModelProperty(value = "创建时间")*/
    private LocalDateTime createTime;

    /*@ApiModelProperty(value = "邮箱")*/
    private String email;

    /*@ApiModelProperty(value = "ip地址")*/
    private String ip;

    /*@ApiModelProperty(value = "昵称")*/
    private String nickname;

    @JsonSerialize(using = ToStringSerializer.class) //系统序列化时，保留相关精度
    /*@ApiModelProperty(value = "博客id")*/
    private int blogId;

    public int getBlogId() {
        return blogId;
    }

    public void setBlogId(int blogId) {
        this.blogId = blogId;
    }

    @JsonSerialize(using = ToStringSerializer.class) //系统序列化时，保留相关精度
    /*@ApiModelProperty(value = "父评论id")*/
    private Long parentCommentId;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Boolean getAdminComment() {
        return adminComment;
    }

    public void setAdminComment(Boolean adminComment) {
        this.adminComment = adminComment;
    }

    public String getAvatar() {
        return avatar;
    }

    public void setAvatar(String avatar) {
        this.avatar = avatar;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public LocalDateTime getCreateTime() {
        return createTime;
    }

    public void setCreateTime(LocalDateTime createTime) {
        this.createTime = createTime;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getIp() {
        return ip;
    }

    public void setIp(String ip) {
        this.ip = ip;
    }

    public String getNickname() {
        return nickname;
    }

    public void setNickname(String nickname) {
        this.nickname = nickname;
    }

    public Long getParentCommentId() {
        return parentCommentId;
    }

    public void setParentCommentId(Long parentCommentId) {
        this.parentCommentId = parentCommentId;
    }

    public List<Comment> getReplyComments() {
        return replyComments;
    }

    public void setReplyComments(List<Comment> replyComments) {
        this.replyComments = replyComments;
    }

    public Comment getParentComment() {
        return parentComment;
    }

    public void setParentComment(Comment parentComment) {
        this.parentComment = parentComment;
    }

    public String getParentNickname() {
        return parentNickname;
    }

    public void setParentNickname(String parentNickname) {
        this.parentNickname = parentNickname;
    }

    //回复评论
    @TableField(exist = false) //查询时过滤非数据库字段
    private List<Comment> replyComments = new ArrayList<>();
    @TableField(exist = false) //查询时过滤非数据库字段
    private Comment parentComment;
    @TableField(exist = false) //查询时过滤非数据库字段
    private String parentNickname;
}
